package com.neutech.controller;

import com.neutech.mapper.RegisterMapper;

import com.neutech.service.RegisterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.lang.String;
import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController//可以省略Respon

public class RegisterController {
    @Autowired
    private RegisterService registerService;

    @ResponseBody
    @RequestMapping("/notregister")
    public List<Map<String, Object>> notregister(@RequestParam Map map)
    {
//        System.out.println(map.get("doctor"));
        return registerService.queryNotRegister((String) map.get("doctor"));
    }
    @ResponseBody
    @RequestMapping("/alregister")
    public List<Map<String, Object>> alregister(@RequestParam Map map)
    {
        System.out.println(map.get("doctor"));
        return registerService.queryAlRegister((String) map.get("doctor"));
    }
    @ResponseBody
    @RequestMapping("/register")
    public List<Map<String, Object>> register()
    {

        return registerService.queryRegister();
    }

    @ResponseBody
    @RequestMapping("/addregister")
    public void addregister(@RequestParam Map map)
    {
        for (Object key : map.keySet()) {
            String value = (String)map.get(key);

            System.out.println(key + " : " + value);

        }
        registerService.addRegister(map);

    }
    @ResponseBody
    @RequestMapping  ("/delregister")
    public void delregister(@RequestParam Map map)
    {

//        for (Object key : map.keySet()) {
//            String value = (String)map.get(key);
//
//            System.out.println(key + " : " + value);
//
//        }

        System.out.println(map.get("num"));
       registerService.delRegister(Integer.parseInt(map.get("num").toString()));

    }

    @ResponseBody
    @RequestMapping("/idregister")
    public List<Map<String, Object>> idregister(@RequestParam Map map)
    {
         List<Map<String, Object>> list = registerService.queryIdRegister(Integer.parseInt(map.get("idnumber").toString()));
        // Integer.parseInt(map.get("idnumber").toString())   (Integer)map.get("idnumber)
        System.out.println(list);
        return registerService.queryIdRegister(Integer.parseInt(map.get("idnumber").toString()));
    }


    @ResponseBody
    @RequestMapping("/upregister")
    public void register(@RequestParam Map map)
    {
        System.out.println(map.get("idnumber"));
        registerService.updateRegisterByIdnumber(Integer.parseInt(map.get("idnumber").toString()));
    }
}
